package com.wx.gof.pattern.structural.composite.interfacetype;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName BookType
 * @Author wx
 * @Description 书
 * @Date 2018-12-09-20:46
 */
public class BookType implements ITreeExtend {
    private String bookTypeName;
    private Integer level;
    private List<ITree> bookTypeList = new ArrayList<>();

    public BookType(String bookTypeName, Integer level) {
        this.bookTypeName = bookTypeName;
        this.level = level;
    }

    @Override
    public Integer getLevel() {
        return this.level;
    }

    @Override
    public void add(ITree iTree) {
        bookTypeList.add(iTree);
    }

    @Override
    public void remove(ITree iTree) {
        bookTypeList.remove(iTree);
    }

    @Override
    public String getName() {
        return this.bookTypeName;
    }

    @Override
    public void printContent() {
        System.out.println("名称 " + this.bookTypeName + " 节点层级" + this.level);
        for (com.wx.gof.pattern.structural.composite.interfacetype.ITree ITree : this.bookTypeList) {
            if (this.level != null) {
                for (int i = 0; i < this.level; i++) {
                    System.out.print("  ");
                }
            }
            ITree.printContent();
        }
    }
}
